﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Conventions;
using FluentNHibernate.Mapping;
using FluentNHibernate.Conventions.Inspections;

namespace Bookkeeping.Persistence.Conventions
{
    public class HasManyConvention : IHasManyConvention
    {
        public void Apply(FluentNHibernate.Conventions.Instances.IOneToManyCollectionInstance instance)
        {
            instance.Key.Column(instance.EntityType.Name + "Id");

            instance.LazyLoad();
            instance.Access.CamelCaseField(CamelCasePrefix.Underscore);

            instance.Cascade.All();
        }
    }
}
